<meta charset="utf-8">
(#) Manually Edited TargetSdkVersion

!!! ERROR: Manually Edited TargetSdkVersion
   This is an error.

Id
:   `EditedTargetSdkVersion`
Summary
:   Manually Edited TargetSdkVersion
Severity
:   Error
Category
:   Correctness
Platform
:   Android
Vendor
:   Android Open Source Project
Feedback
:   https://issuetracker.google.com/issues/new?component=192708
Since
:   8.1.0 (July 2023)
Affects
:   Gradle build files
Editing
:   This check runs on the fly in the IDE editor
Implementation
:   [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/GradleDetector.kt)
Tests
:   [Source Code](https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:lint/libs/lint-tests/src/test/java/com/android/tools/lint/checks/GradleDetectorTest.kt)

Updating the `targetSdkVersion` of an app is seemingly easy: just
increment the `targetSdkVersion` number in the manifest file!

But that's not actually safe. The `targetSdkVersion` controls a wide
range of behaviors that change from release to release, and to update,
you should carefully consult the documentation to see what has changed,
how your app may need to adjust, and then of course, carefully test
everything.

In new versions of Android Studio, there is a special migration
assistant, available from the tools menu (and as a quickfix from this
lint warning) which analyzes your specific app and filters the set of
applicable migration steps to those needed for your app.

This lint check does something very simple: it just detects whether it
looks like you've manually edited the targetSdkVersion field in a
build.gradle file. Obviously, as part of doing the above careful steps,
you may end up editing the value, which would trigger the check -- and
it's safe to ignore it; this lint check *only* runs in the IDE, not from
the command line; it's sole purpose to bring *awareness* to the (many)
developers who haven't been aware of this issue and have just bumped the
targetSdkVersion, recompiled, and uploaded their updated app to the
Google Play Store, sometimes leading to crashes or other problems on
newer devices.

(##) Suppressing

You can suppress false positives using one of the following mechanisms:

* Using a suppression comment like this on the line above:

  ```kt
  //noinspection EditedTargetSdkVersion
  problematicStatement()
  ```

* Using a special `lint.xml` file in the source tree which turns off
  the check in that folder and any sub folder. A simple file might look
  like this:
  ```xml
  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;lint&gt;
      &lt;issue id="EditedTargetSdkVersion" severity="ignore" /&gt;
  &lt;/lint&gt;
  ```
  Instead of `ignore` you can also change the severity here, for
  example from `error` to `warning`. You can find additional
  documentation on how to filter issues by path, regular expression and
  so on
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/lintxml.md.html).

* In Gradle projects, using the DSL syntax to configure lint. For
  example, you can use something like
  ```gradle
  lintOptions {
      disable 'EditedTargetSdkVersion'
  }
  ```
  In Android projects this should be nested inside an `android { }`
  block.

* For manual invocations of `lint`, using the `--ignore` flag:
  ```
  $ lint --ignore EditedTargetSdkVersion ...`
  ```

* Last, but not least, using baselines, as discussed
  [here](https://googlesamples.github.io/android-custom-lint-rules/usage/baselines.md.html).

<!-- Markdeep: --><style class="fallback">body{visibility:hidden;white-space:pre;font-family:monospace}</style><script src="markdeep.min.js" charset="utf-8"></script><script src="https://morgan3d.github.io/markdeep/latest/markdeep.min.js" charset="utf-8"></script><script>window.alreadyProcessedMarkdeep||(document.body.style.visibility="visible")</script>